<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">

            <h:form id="customerCreate" enctype="multipart/form-data">
                <h1 class="title">
                    <a href="#" class="back" onclick="history.go(-1)"/>
                    Pesquisar
                </h1>
                <p:messages showDetail="true" autoUpdate="true"  /> 
                <div class="row">
                    <div class="twelve columns"> 
                        <fieldset>
                            <legend> <h4 style="margin:0 0 10px 0">Filtro</h4></legend>
                            <p:panel id="customerPrimary" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix ">

                                <div class="grid_25">

                                    <p:outputLabel  for="codlaudo" value="Código Laudo:" styleClass="grid_4"/>
                                    <p:inputText id="codlaudo" value="#{managerSearchAppraisal.codLaudo}" styleClass="grid_5" />
                                    <p:outputLabel for="codatendimento"  value="Código Atendimento:" styleClass="grid_4"/>
                                    <p:inputText id="codatendimento" value="#{managerSearchAppraisal.codAtendimento}" styleClass="grid_5" />

                                    <div class="clear"/>
                                    <p:outputLabel for="name" value="Nome Paciente:" styleClass="grid_4"/>
                                    <p:inputText id="name" value="#{managerSearchAppraisal.nomePaciente}" styleClass="grid_14" />

                                    <div class="clear"/>

                                    <p:outputLabel value="Médico:" styleClass="grid_4"/>
                                    <p:autoComplete value="#{managerSearchAppraisal.doctor}"  
                                                    id="selectDoctor" completeMethod="#{managerDoctor.autocomplete}"  
                                                    var="d" itemLabel="#{d.name}" itemValue="#{d}" forceSelection="true"
                                                    styleClass="grid_14" dropdown="true" panelStyle="max-height:200px;" 
                                                    converter="#{autocompleteconverter}" >  
                                    </p:autoComplete>

                                    <div class="clear"/>
                                    
                                    <p:outputLabel value="Situação: " styleClass="grid_4"/> 
                                    <div class="grid_5">
                                        <p:selectOneMenu  style="width: 108%;" panelStyle="width:150px;" 
                                                          value="#{managerSearchAppraisal.situationAppraisal}" >   
                                            <f:selectItem  itemValue="#{null}" itemLabel=""/>
                                            <f:selectItems value="#{managerSearchAppraisal.selectSituationAppraisal()}" />
                                        </p:selectOneMenu>
                                    </div>
                                    <p:outputLabel   value="Data:" styleClass="grid_4"/>
                                    <p:calendar styleClass="grid_5" showOn="button" pattern="dd/MM/yyyy" 
                                                value="#{managerSearchAppraisal.data}" />

                                    <div class="clear"/>
                                    <div class="buttonAction">
                                        <p:commandButton value="Pesquisar" icon="ui-icon-search"
                                                         update="@form, tableAppraisal" actionListener="#{managerSearchAppraisal.search()}"
                                                         styleClass="ui-priority-primary" />
                                        <p:button href="indexAppraisal.xhtml" value="Cancelar" 
                                                  icon="ui-icon-arrowreturnthick-1-w" />
                                    </div>
                                </div>
                            </p:panel>
                        </fieldset>
                        <fieldset>
                            <legend> <h4 style="margin:0 0 10px 0">Resultado</h4></legend>
                            <p:panel id="resultPanel" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix " >

                                <p:dataTable id="tableAppraisal" var="ap" value="#{managerSearchAppraisal.searchAppraisal}" 
                                             styleClass="grid_24"
                                             rowIndexVar="rowid"
                                             rowKey="#{ap.id}"
                                             rows="15" paginator="true"  
                                             paginatorPosition="bottom"
                                             emptyMessage="Nenhum registro"
                                             >  
                                    <f:facet name="header">
                                        Pendentes
                                    </f:facet>  
                                    <p:column headerText="Ação" width="5">

                                        <p:button icon="ui-icon-search" 
                                                  outcome="createAppraisal.xhtml?appraisalEdit=#{ap.id}"
                                                  alt="Visualizar Modelo" title="Visualizar Modelo"
                                                  style="width: 25px; position: relative;"/>

                                    </p:column>
                                    <p:column headerText="Cód. Laudo" style="white-space: pre-wrap;" width="400">  
                                        <h:outputText value="#{ap.id}"/>
                                    </p:column>  
                                    <p:column headerText="Cód. Atendimento" style="white-space: pre-wrap;" width="400">  
                                        <h:outputText value="#{ap.diary.id}"/>
                                    </p:column>  
                                    <p:column headerText="Médico" style="white-space: pre-wrap;" width="400">  
                                        <h:outputText value="#{ap.doctor.name}"/>
                                    </p:column> 
                                    <p:column headerText="Procedimento" style="white-space: pre-wrap;" width="400">  
                                        <h:outputText value="#{ap.diary.procedure.name}"/>
                                    </p:column> 
                                    <p:column headerText="Paciente" width="400" style="white-space: pre-wrap;">  
                                        <h:outputText value="#{ap.diary.customer.name}"/>
                                    </p:column>
                                    <p:column headerText="Data" style="white-space: pre-wrap;" width="400">  
                                        <h:outputText value="#{ap.diary.startTime}">
                                            <f:convertDateTime pattern="dd/MM/yyyy" locale="pt,BR"/>
                                        </h:outputText>
                                    </p:column>  
                                    <p:column headerText="Situação" width="400" style="white-space: pre-wrap;">  
                                        <h:outputText value="#{ap.situationAppraisal.desc}"/>
                                    </p:column>


                                </p:dataTable>
                            </p:panel>
                        </fieldset>
                    </div>
                </div>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
